<?php

declare(strict_types=1);

namespace App\Entity;

use App\Models\Cooperator;

class CooperatorEntity extends ABaseEntity
{
    public function __construct(Cooperator $model = null)
    {
        if ($model === null) {
            $model = new Cooperator();
        }
        $this->model = $model;
    }

    /**
     * @return CooperatorEntity
     */
    public static function findByName(string $name)
    {
        $model = Cooperator::where('name', $name)->first();
        if ($model === null) {
            return null;
        }

        return new self($model);
    }

    public static function findLikeByName(string $name)
    {
        $entityList = [];
        $result     = Cooperator::where('name', 'LIKE', '%' . $name . '%')->get();
        if ($result) {
            foreach ($result as $coModel) {
                $entityList[] = new self($coModel);
            }
        }

        return $entityList;
    }

    /**
     * @return string
     */
    public static function getChannelNameById(int $channelId)
    {
        $entity = self::find($channelId);

        return $entity === null ? '' : $entity->getName();
    }

    /**
     * @return int
     */
    public function getId()
    {
        return (int) $this->model->id;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->model->name;
    }

    /**
     * @param $name string
     */
    public function setName($name)
    {
        $this->model->name = $name;
    }

    public function setCategoryId(int $categoryId)
    {
        $this->model->category_id = $categoryId;
    }

    /**
     * @return int
     */
    public function getCategoryId()
    {
        return (int) $this->model->category_id;
    }

    public function setCategory(string $category)
    {
        $this->model->category = $category;
    }

    /**
     * @return string
     */
    public function getCategory()
    {
        return (string) $this->model->category;
    }

    public function setBegin(string $begin)
    {
        $this->model->begin = $begin;
    }

    /**
     * @return string
     */
    public function getBegin()
    {
        return (string) $this->model->begin;
    }

    public function setEnd(string $end)
    {
        $this->model->end = $end;
    }

    /**
     * @return string
     */
    public function getEnd()
    {
        return (string) $this->model->end;
    }

    public function getBusinessLicenseImg(): string
    {
        return (string) $this->model->business_license_img;
    }

    public function setBusinessLicenseImg(string $businessLicenseImg): void
    {
        $this->model->business_license_img = $businessLicenseImg;
    }

    public function getIdBackView(): string
    {
        return (string) $this->model->id_back_view;
    }

    public function setIdBackView(string $idBackView): void
    {
        $this->model->id_back_view = $idBackView;
    }

    public function getIdFrontView(): string
    {
        return (string) $this->model->id_front_view;
    }

    public function setIdFrontView(string $idFrontView): void
    {
        $this->model->id_front_view = $idFrontView;
    }

    public function getPhone(): string
    {
        return (string) $this->model->phone;
    }

    public function setPhone(string $phone): void
    {
        $this->model->phone = $phone;
    }

    public function getLandlinePhone(): string
    {
        return (string) $this->model->landline_phone;
    }

    public function setLandlinePhone(string $landlinePhone): void
    {
        $this->model->landline_phone = $landlinePhone;
    }

    public function getIntro(): string
    {
        return (string) $this->model->intro;
    }

    public function setIntro(string $intro): void
    {
        $this->model->intro = $intro;
    }

    public function getCityIds(): string
    {
        return (string) $this->model->cityIds;
    }

    public function setCityIds(string $cityIds): void
    {
        $this->model->cityIds = $cityIds;
    }

    public function getBankAccount(): string
    {
        return (string) $this->model->bank_account;
    }

    public function setBankAccount(string $bankAccount): void
    {
        $this->model->bank_account = $bankAccount;
    }

    public function getContact(): string
    {
        return (string) $this->model->contact;
    }

    public function setContact(string $contact): void
    {
        $this->model->contact = $contact;
    }

    public function getContactId(): int
    {
        return (int) $this->model->contact_id;
    }

    public function setContactId(int $contactId): void
    {
        $this->model->contact_id = $contactId;
    }

    public function getStatus(): int
    {
        return (int) $this->model->status;
    }

    public function setStatus(int $status): void
    {
        $this->model->status = $status;
    }

    public function getCooperatorContact(): string
    {
        return (string) $this->model->cooperator_contact;
    }

    public function setCooperatorContact(string $cooperatorContact): void
    {
        $this->model->cooperator_contact = $cooperatorContact;
    }
}
